from pynput import keyboard
from pynput.mouse import Controller, Button


def on_activate_h():
    print('<ctrl>+<alt>+h pressed')


def on_activate_i():
    print('<ctrl>+<alt>+i pressed')


def on_activate_q():
    print('<shift>+<alt>+q pressed')


# 按下 ctrl + q 触发鼠标左键连点
def on_activate_q2():
    print('<ctrl>+q pressed')
    mouse = Controller()
    print('mouse position:', mouse.position)
    # 点击鼠标 50 次
    mouse.click(Button.left, 50)


with keyboard.GlobalHotKeys({
    '<ctrl>+<alt>+h': on_activate_h,
    '<ctrl>+<alt>+i': on_activate_i,
    '<shift>+<alt>+q': on_activate_q,
    '<ctrl>+q': on_activate_q2,
}) as h:
    h.join()
